
#include <BTextEdit>
#include <BClass>
#include <BScript>

#include "ClassConsole.h"

ClassConsole::ClassConsole() : BClass("Console")
{
	insertVariant("TextEdit", "board");
	insertMethod("Console()", &ClassConsole::create);
	insertMethod("void clear()", &ClassConsole::clear);
	insertMethod("void output(string)", &ClassConsole::output);
}

BClass* ClassConsole::clone() const
{
	ClassConsole* cls = new ClassConsole();
	cls->copy(this);
	return cls;
}

void ClassConsole::create(int argc, BValue* argv)
{

}
void ClassConsole::clear(int argc, BValue* argv)
{
	if (BTextEdit* textEdit = this->value("board"))
	{
		textEdit->clear();
	}
}
void ClassConsole::output(int argc, BValue* argv)
{
	if (BTextEdit* textEdit = this->value("board"))
	{
		const BString& text = argv[1];
		textEdit->addText(text);
		textEdit->addText('\n');
	}
}
